
#include "gfs_api.h"
#include "gfs_use.h"
#include "gfs.h"

#ifdef GTREE_FILE_COURCE
static DfBalancedRecord gtreeParHead	=	{0};
int api_TremParInit(void *pData,int size)
{
	int ret=BalancedAccountInit(&gtreeParHead,GFS_PAR_ADDR,GFS_PAR_SIZE,size);
	if(size == ret && pData != NULL) {
		return BalancedAccountRead(&gtreeParHead,0,pData);	
	}
	return ret;
}

int api_TremParRead(void *pData)
{
	return BalancedAccountRead(&gtreeParHead,0,pData);	
}

int api_TremParWrite(void *pData)
{
	return BalancedAccountSave(&gtreeParHead,pData);	
}

extern void gfs_evn_init();

int api_fileInit(void)
{
	gfs_evn_init();
	SPI_Flash_init();
	int ret = BalancedAccountCheck(GFS_PAR_ADDR,GFS_PAR_SIZE);
	return gfs_Init(GFS_FILE_START,GFS_FILE_SIZE,GFS_FILE_HDNM,ret);
}	

int api_fileFomat(const char* pKey)
{
	if(strcmp(pKey,"123456")==0)
		return gfs_Fomat(NULL);
	return -1;
}	


/*
gFILE pFd_gfs=NULL;
pFd_gfs=gfs_open(pInPar->pStr,pInPar->pNext->uData);
ret=gfs_write(pFd_gfs,(u8*)pInPar->pStr,pInPar->Len);
ret=gfs_read(pFd_gfs,(u8*)pData,pInPar->Len);
ret = gfs_seek(pFd_gfs, pInPar->uData, pInPar->pNext->uData);
ret=gfs_close(pFd_gfs);
ret=gfs_remove(pInPar->pStr);


*/



#endif
